package com.yonyou.cyxdms.basedata.service.controller.vehicleproduct;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yonyou.cyx.framework.util.bean.ApplicationContextHelper;
import com.yonyou.cyx.function.bean.dto.ImportResultDto;
import com.yonyou.cyxdms.basedata.service.dto.CarPriceDTO;
import com.yonyou.cyxdms.basedata.service.dto.vehiclemodel.*;
import com.yonyou.cyxdms.basedata.service.service.brand.BrandService;
import com.yonyou.cyxdms.basedata.service.service.configure.PackageService;
import com.yonyou.cyxdms.basedata.service.service.model.ModelService;
import com.yonyou.cyxdms.basedata.service.service.option.VsOptionService;
import com.yonyou.cyxdms.basedata.service.service.series.SeriesService;
import com.yonyou.cyxdms.basedata.service.util.EasyPoiUtil;
import com.yonyou.cyxdms.basedata.service.vo.CarPriceImportVO;
import com.yonyou.cyxdms.basedata.service.vo.brand.BrandDictVO;
import com.yonyou.cyxdms.basedata.service.vo.brand.VehicleProductBrandVO;
import com.yonyou.cyxdms.basedata.service.vo.model.GmsModelVO;
import com.yonyou.cyxdms.basedata.service.vo.model.ModelDictVO;
import com.yonyou.cyxdms.basedata.service.vo.model.VehicleProductModelVO;
import com.yonyou.cyxdms.basedata.service.vo.option.VehicleProductOptionVO;
import com.yonyou.cyxdms.basedata.service.vo.packages.PackageDictVO;
import com.yonyou.cyxdms.basedata.service.vo.packages.VehicleProductPackageVO;
import com.yonyou.cyxdms.basedata.service.vo.series.SeriesDictVO;
import com.yonyou.cyxdms.basedata.service.vo.series.VehicleProductSeriesVO;
import com.yonyou.cyxdms.framework.bean.dto.user_info.LoginInfoDto;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * 品牌车系车型配置的控制类
 *
 * @author renwd
 * @since 2019/7/10
 */

@Api(value = "BrandCarsModelsController", tags = "品牌车系车型配置的控制类")
@RestController
@RequestMapping("/vehicleProduct")
public class BrandCarsModelsController {

    @Autowired
    private BrandService brandService;

    @Autowired
    private SeriesService seriesService;

    @Autowired
    private PackageService packageService;

    @Autowired
    private ModelService modelService;
    
    @Autowired
    VsOptionService vsOptionService;

    /**
     * 根据查询条件返回对应的品牌数据（pc）
     *
     * @param brandQueryDTO
     * @return java.util.List<com.yonyou.cyxdms.basedata.service.vo.brand.VehicleProductBrandVO>
     * @author renwd
     * @since 2019/7/10
     */
    @ApiOperation(notes = "根据查询条件返回对应的品牌数据", value = "根据查询条件返回对应的品牌数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/brands")
    public IPage<VehicleProductBrandVO> queryVehicleProductBrand(@ApiParam(name = "pageNum", value = "当前页") @RequestParam("pageNum") Long current,
                                                                 @ApiParam(name = "limit", value = "分页大小") @RequestParam("limit") Long size,
                                                                 BrandQueryDTO brandQueryDTO) {
        Page<VehicleProductBrandVO> page = new Page(current, size);
        return brandService.queryVehicleProductBrand(page, brandQueryDTO);
    }

    /**
     * 新增品牌
     *
     * @param brandDto
     * @return java.lang.Integer
     * @author renwd
     * @since 2019/7/11
     */
    @ApiOperation(notes = "新增品牌", value = "新增品牌")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PostMapping("/brands")
    public Integer addBrand(@Valid @RequestBody BrandModifyDTO brandDto) {
        return brandService.addBrand(brandDto);
    }

    /**
     * 品牌修改
     *
     * @param id
     * @param brandDto
     * @return java.lang.Integer
     * @author renwd
     * @since 2019/7/16
     */
    @ApiOperation(notes = "品牌修改", value = "品牌修改")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PutMapping("/brands/{id}")
    public Integer modifyBrand(@PathVariable("id") Long id, @RequestBody BrandModifyDTO brandDto) {
        return brandService.modifyBrand(id, brandDto);
    }

    /**
     * 有效品牌下拉框
     *
     * @param queryParam
     * @return java.util.List<com.yonyou.cyxdms.basedata.service.vo.brand.BrandDictVO>
     * @author renwd
     * @since 2019/7/16
     */
    @ApiOperation(notes = "有效品牌下拉框", value = "有效品牌下拉框")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/brandsdict")
    public List<BrandDictVO> queryBrandDict(@RequestParam Map<String, Object> queryParam) {
        return brandService.queryBrandDict(queryParam);
    }

    /**
     * 提供给查询的下拉框的方法
     *
     * @param queryParam
     * @return java.util.List<com.yonyou.cyxdms.basedata.service.vo.brand.BrandDictVO>
     * @author renwd
     * @since 2019/7/17
     */
    @ApiOperation(notes = "提供给查询的下拉框的方法", value = "提供给查询的下拉框的方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/brandsqueryall")
    public List<BrandDictVO> queryBrandsAll(@RequestParam Map<String, Object> queryParam) {
        return brandService.queryBrandsAll(queryParam);
    }

    /**
     * 品牌导出
     *
     * @param queryParam 查询条件
     * @param request
     * @param response
     * @return void
     * @author renwd
     * @since 2019/7/12
     */
    @ApiOperation(notes = "品牌导出", value = "品牌导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/brands/export/excel")
    public void exportBrands(@RequestParam Map<String, Object> queryParam, HttpServletRequest request,
                             HttpServletResponse response) {
        brandService.exportExcelForBrand(queryParam, request, response);
    }

    /**
     * 导入品牌
     *
     * @param importFile
     * @return java.util.List<com.yonyou.cyxdms.basedata.service.dto.vehiclemodel.BrandImportDTO>
     * @author renwd
     * @since 2019/7/22
     */
    @ApiOperation(notes = "导入品牌", value = "导入品牌")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PostMapping("/brands/import")
    public List<BrandImportDTO> importBrand(@RequestParam(value = "file") MultipartFile importFile) {
        return brandService.importBrand(importFile);
    }


    /**
     * 根据查询条件返回对应的车系数据
     *
     * @param current
     * @param size
     * @param seriesQueryDTO
     * @author Tansj
     * @since 2019/11/15
     */
    @GetMapping("/seriess")
    @ApiOperation(notes = "根据查询条件返回对应的车系数据", value = "根据查询条件返回对应的车系数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    public IPage<VehicleProductSeriesVO> queryVehicleProductSeries(@ApiParam(name = "pageNum", value = "当前页") @RequestParam("pageNum") Long current,
                                                                   @ApiParam(name = "limit", value = "分页大小") @RequestParam("limit") Long size,
                                                                   SeriesQueryDTO seriesQueryDTO) {
        Page<VehicleProductSeriesVO> page = new Page(current, size);
        return seriesService.queryVehicleProductSeries(page, seriesQueryDTO);
    }

    /**
     * 新增车系
     *
     * @param seriesModifyDTO
     * @return java.lang.Integer
     * @author renwd
     * @since 2019/7/11
     */
    @ApiOperation(notes = "新增车系", value = "新增车系")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PostMapping("/seriess")
    public Integer addSeries(@Valid @RequestBody SeriesModifyDTO seriesModifyDTO) {
        return seriesService.addSeries(seriesModifyDTO);
    }

    /**
     * 修改车系
     *
     * @param id
     * @param seriesModifyDTO
     * @return java.lang.Integer
     * @author renwd
     * @since 2019/7/16
     */
    @ApiOperation(notes = "修改车系", value = "修改车系")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PutMapping("/seriess/{id}")
    public Integer modifySeries(@PathVariable("id") Long id, @RequestBody SeriesModifyDTO seriesModifyDTO) {
        return seriesService.modifySeries(id, seriesModifyDTO);
    }

    /**
     * 有效车系下拉框
     *
     * @param queryParam
     * @return java.util.List<com.yonyou.cyxdms.basedata.service.vo.series.SeriesDictVO>
     * @author renwd
     * @since 2019/7/16
     */
    @ApiOperation(notes = "有效车系下拉框", value = "有效车系下拉框")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/brandsdict/{brandsid}/seriessdict")
    public List<SeriesDictVO> querySeriesDict(@PathVariable String brandsid, @RequestParam Map<String, Object> queryParam) {
        queryParam.put("code", brandsid);
        return seriesService.querySeriesDict(queryParam);
    }

    /**
     * 车系导出
     *
     * @param queryParam
     * @param request
     * @param response
     * @return void
     * @author renwd
     * @since 2019/7/15
     */
    @ApiOperation(notes = "车系导出", value = "车系导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/seriess/export/excel")
    public void exportSeries(@RequestParam Map<String, Object> queryParam, HttpServletRequest request,
                             HttpServletResponse response) {
        seriesService.exportExcelForSeries(queryParam, request, response);
    }

    /**
     * 导入车系
     *
     * @param importFile
     * @return java.util.List<com.yonyou.cyxdms.basedata.service.dto.vehiclemodel.SeriesImportDTO>
     * @author renwd
     * @since 2019/7/22
     */
    @ApiOperation(notes = "导入车系", value = "导入车系")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PostMapping("/seriess/import")
    public List<SeriesImportDTO> importSeries(@RequestParam(value = "file") MultipartFile importFile) {
        return seriesService.importSeries(importFile);
    }

    /**
     * 根据查询条件返回对应的车型数据
     *
     * @param current
     * @param size
     * @param modelQueryDTO
     * @author Tansj
     * @since 2019/11/15
     */
    @GetMapping("/models")
    @ApiOperation(notes = "根据查询条件返回对应的车型数据", value = "根据查询条件返回对应的车型数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    public IPage<VehicleProductModelVO> queryVehicleProductModels(@ApiParam(name = "pageNum", value = "当前页") @RequestParam("pageNum") Long current,
                                                                  @ApiParam(name = "limit", value = "分页大小") @RequestParam("limit") Long size,
                                                                  ModelQueryDTO modelQueryDTO) {
        Page<VehicleProductModelVO> page = new Page(current, size);
        return modelService.queryVehicleProductModel(page, modelQueryDTO);
    }



    /**
     * 	 不翻页获取所有车型数据
     * 	 前台内存设置内存分页
     *
     * @param queryCondition 查询条件
     * @return List<ModelDictVO> 对象
     * @author wangsht
     * @since 2020-12-22
     */
    @ResponseBody
    @GetMapping(value="/models/all")
    @ApiOperation(value = "车型列表查询", notes = "车型列表查询", httpMethod = "GET",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiImplicitParams({@ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string", paramType = "header")})
    public List<ModelDictVO> searchConstructionList (@RequestParam Map<String,Object> queryCondition) {
        LoginInfoDto loginInfo = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        if(queryCondition!=null){
            queryCondition.put("appId",loginInfo.getAppId());
        }
        return modelService.queryDcsModelDictAll(queryCondition);
    }
    /**
     * 新增车型
     *
     * @param modelDTO
     * @return java.lang.Integer
     * @author renwd
     * @since 2019/7/11
     */
    @ApiOperation(notes = "新增车型", value = "新增车型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PostMapping("/models")
    public Integer addModel(@Valid @RequestBody ModelModifyDTO modelDTO) {
        return modelService.addModel(modelDTO);
    }

    /**
     * 修改车型
     *
     * @param id
     * @param modelDto
     * @return java.lang.Integer
     * @author renwd
     * @since 2019/7/16
     */
    @ApiOperation(notes = "修改车型", value = "修改车型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PutMapping("/models/{id}")
    public Integer modifyModel(@PathVariable("id") Long id, @RequestBody ModelModifyDTO modelDto) {
        return modelService.modifyModel(id, modelDto);
    }

    /**
     * 车型导出
     *
     * @param queryParam
     * @param request
     * @param response
     * @return void
     * @author renwd
     * @since 2019/7/15
     */
    @ApiOperation(notes = "车型导出", value = "车型导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/models/export/excel")
    public void exportModels(@RequestParam Map<String, Object> queryParam, HttpServletRequest request,
                             HttpServletResponse response) {
        modelService.exportExcelForModel(queryParam, request, response);
    }

    /**
     * 下拉框查询车型信息
     *
     * @param seriessid
     * @param queryParam
     * @return java.util.List<com.yonyou.cyxdms.basedata.service.vo.model.ModelDictVO>
     * @author renwd
     * @since 2019/7/16
     */
    @ApiOperation(notes = "有效车型下拉框", value = "有效车型下拉框")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/brandsdict/{brandsid}/seriessdict/{seriessid}/modelsdict")
    public List<ModelDictVO> queryModelDict(@PathVariable("seriessid") String seriessid, @RequestParam Map<String, Object> queryParam) {
        queryParam.put("code", seriessid);
        return modelService.queryModelDict(queryParam);
    }

    /**
     * 导入车型
     *
     * @param importFile
     * @return java.util.List<com.yonyou.cyxdms.basedata.service.dto.vehiclemodel.ModelImportDTO>
     * @author renwd
     * @since 2019/7/22
     */
    @ApiOperation(notes = "导入车型", value = "导入车型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PostMapping("/model/import")
    public List<ModelImportDTO> importModels(@RequestParam(value = "file") MultipartFile importFile) {
        return modelService.importModel(importFile);
    }

    /**
     * 根据查询条件返回对应的配置数据
     *
     * @param current
     * @param size
     * @param packageQueryDTO
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.yonyou.cyxdms.basedata.service.vo.packages.VehicleProductPackageVO>
     * @author renwd
     * @since 2019/7/10
     */
    @GetMapping("/packages")
    @ApiOperation(notes = "根据查询条件返回对应的配置数据", value = "根据查询条件返回对应的配置数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    public IPage<VehicleProductPackageVO> queryVehicleProductPackage(@ApiParam(name = "pageNum", value = "当前页") @RequestParam("pageNum") Long current,
                                                                     @ApiParam(name = "limit", value = "分页大小") @RequestParam("limit") Long size,
                                                                     PackageQueryDTO packageQueryDTO) {
        Page<VehicleProductPackageVO> page = new Page(current, size);
        return packageService.queryVehicleProductPackage(page, packageQueryDTO);
    }

    /**
     * 根据查询条件返回对应的选装数据
     *
     * @param current
     * @param size
     * @param optionQueryDTO
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.yonyou.cyxdms.basedata.service.vo.packages.VehicleProductPackageVO>
     * @author zhangys
     * @since 2020/2/24
     */
    @GetMapping("/options")
    @ApiOperation(notes = "根据查询条件返回对应的选装数据", value = "根据查询条件返回对应的选装数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    public IPage<VehicleProductOptionVO> queryVehicleProductOption(@ApiParam(name = "pageNum", value = "当前页") @RequestParam("pageNum") Long current,
                                                                     @ApiParam(name = "limit", value = "分页大小") @RequestParam("limit") Long size,
                                                                     OptionQueryDTO optionQueryDTO) {
        Page<VehicleProductOptionVO> page = new Page(current, size);
        return vsOptionService.queryVehicleProductOption(page, optionQueryDTO);
    }

    /**
     * 导入选装模板下载
     *
     * @author mayi
     */
    @GetMapping(value = "/downloadUseModelExcel")
    @ApiOperation(value = "模板下载", notes = "模板下载", httpMethod = "GET")
    public void downloadDealersExcel(HttpServletResponse response) throws IOException {
        vsOptionService.downloadUseModelExcel(response);
    }

    /**
     * 导入选装
     *
     * @author mayi
     */
    @PostMapping("/importUseModel")
    @ApiOperation(value = "新增页面 上传", notes = "新增页面 上传", httpMethod = "POST")
    public Map<String,List> importDealers(@RequestParam(value = "file") MultipartFile importFile) throws Exception{
        List<VehicleProductOptionVO> dealerList = EasyPoiUtil.importExcel(importFile, 0, 1, VehicleProductOptionVO.class);
        return vsOptionService.getOptionInfoByExcel(dealerList);
    }


    /**
     * 根据查询条件返回对应的选装数据(不分页)
     *
     * @param optionQueryDTO
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.yonyou.cyxdms.basedata.service.vo.packages.VehicleProductPackageVO>
     * @author mayi
     * @since 2021/12/02
     */
    @GetMapping("/optionsNoPage")
    @ApiOperation(notes = "根据查询条件返回对应的选装数据", value = "根据查询条件返回对应的选装数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", dataType = "Long", paramType = "header", value = "userId"),
    })
    public List<VehicleProductOptionVO> queryVehicleProductOptionNoPage(OptionQueryDTO optionQueryDTO) {
        return vsOptionService.queryVehicleProductOptionNoPage(optionQueryDTO);
    }

    /**
     * 新增配置
     *
     * @param packageModifyDTO
     * @return java.lang.Integer
     * @author Tansj
     * @since 2019/11/18
     */
    @ApiOperation(notes = "新增配置", value = "新增配置")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PostMapping("/packages")
    public Integer addPackage(@Valid @RequestBody PackageModifyDTO packageModifyDTO) {
        return packageService.addPackage(packageModifyDTO);
    }
    
    /**
     * 新增选装
     *
     * @param optionModifyDTO
     * @return java.lang.Integer
     * @author zhangys
     * @since 2020/2/25
     */
    @ApiOperation(notes = "新增选装", value = "新增选装")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PostMapping("/options")
    public Integer addOption(@Valid @RequestBody OptionModifyDTO optionModifyDTO) {
        return vsOptionService.addOption(optionModifyDTO);
    }

    /**
     * 修改配置信息
     *
     * @param id
     * @param packageModifyDTO
     * @return java.lang.Integer
     * @author Tansj
     * @since 2019/11/18
     */
    @ApiOperation(notes = "修改配置", value = "修改配置")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PutMapping("/packages/{id}")
    public Integer modifyConfig(@PathVariable("id") Long id, @RequestBody PackageModifyDTO packageModifyDTO) {
        return packageService.modifyConfig(id, packageModifyDTO);
    }
    
    /**
     * 修改选装信息
     *
     * @param id
     * @param optionModifyDTO
     * @return java.lang.Integer
     * @author zhangys
     * @since 2020/2/25
     */
    @ApiOperation(notes = "修改选装", value = "修改选装")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PutMapping("/options/{id}")
    public Integer modifyOption(@PathVariable("id") Long id, @RequestBody OptionModifyDTO optionModifyDTO) {
        return vsOptionService.modifyOption(id, optionModifyDTO);
    }

    /**
     * 配置导出
     *
     * @param queryParam
     * @param request
     * @param response
     * @return void
     * @author renwd
     * @since 2019/7/15
     */
    @ApiOperation(notes = "配置导出", value = "配置导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/packages/export/excel")
    public void exportConfis(@RequestParam Map<String, Object> queryParam, HttpServletRequest request,
                             HttpServletResponse response) {
        packageService.exportExcelForPackage(queryParam, request, response);
    }

    /**
     * 有效配置下拉框
     *
     * @param modelsid
     * @param queryParam
     * @return java.util.List<com.yonyou.cyxdms.basedata.service.vo.packages.PackageDictVO>
     * @author renwd
     * @since 2019/7/16
     */
    @ApiOperation(notes = "有效配置下拉框", value = "有效配置下拉框")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/brandsdict/{brandsid}/seriessdict/{seriessid}/modelsdict/{modelsid}/packagesdict")
    public List<PackageDictVO> queryPackageDict(@PathVariable("modelsid") String modelsid, @RequestParam Map<String, Object> queryParam) {
        queryParam.put("code", modelsid);
        return packageService.queryPackageDict(queryParam);
    }

    /**
     * 导入配置
     *
     * @param importFile
     * @return java.util.List<com.yonyou.cyxdms.basedata.service.dto.vehiclemodel.PackageImportDTO>
     * @author renwd
     * @since 2019/7/22
     */
    @ApiOperation(notes = "导入配置", value = "导入配置")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PostMapping("/packages/import")
    public List<PackageImportDTO> importPackages(@RequestParam(value = "file") MultipartFile importFile) {
        return packageService.importPackages(importFile);
    }

    /**
     * dms端 查询集团端
     *
     * @param queryParam
     * @return java.util.List<com.yonyou.cyxdms.basedata.service.vo.model.GmsModelVO>
     * @author renwd
     * @since 2019/7/18
     */
    @ApiOperation(notes = "dms端 查询集团端", value = "dms端 查询集团端")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/gmsModels")
    public List<GmsModelVO> queryGmsModel(@RequestParam Map<String, Object> queryParam) {
        return modelService.queryGmsModel(queryParam);
    }

    /**
     * @Description: 获取活动车型名称
     * @Param: [appId, brandCode, seriesCode, modelCode, packageCode]
     * @Return: String
     * @Author: lijun
     * @Date: 16:55 2019/9/10
     **/
    @GetMapping("/open/getModelName")
    public String getModelName(@RequestParam String appId,
                               @RequestParam String brandCode,
                               @RequestParam(required = false) String seriesCode,
                               @RequestParam(required = false) String modelCode,
                               @RequestParam(required = false) String packageCode,
                               @RequestParam(required = false) String colorCode) {
        return packageService.getModelName(appId, brandCode, seriesCode, modelCode, packageCode, colorCode);
    }

    /**
     * 导入车辆主数据价格
     *  2019/11/27 + 新增 分类代码、储备高限、储备低限、销售底价的导入功能
     * @author ysj
     * @date 2019/09/20
     * @param importFile
     * @return
     */
    @ApiOperation(notes = "导入车辆主数据价格", value = "导入车辆主数据价格")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PostMapping("/car/importCarPrice")
    public ImportResultDto<CarPriceImportVO> importCarPrice(@RequestParam(value = "file") MultipartFile importFile) {
        return packageService.importCarPrice(importFile);
    }


    /**
     * 修改车辆销售指导价
     *
     * @author ysj
     * @date 2019/09/21
     * @param carPriceDTO
     * @return
     */
    @ApiOperation(notes = "修改车辆销售指导价", value = "修改车辆销售指导价")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @PutMapping("/car/editCarPrice")
    public Integer editCarPrice(@RequestBody  CarPriceDTO carPriceDTO) {
        return packageService.editCarPrice(carPriceDTO);
    }

    /**
     * 品系型查询界面品牌下拉框
     *
     * @author Tansj
     * @since 2019/11/15
     */
    @ApiOperation(notes = "品系型查询界面品牌下拉框", value = "品系型查询界面品牌下拉框")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/queryBrandDictAll")
    public List<BrandDictVO> queryBrandDictAll() {
        return brandService.queryBrandDictAll();
    }

    /**
     * 品系型查询界面车系下拉框
     *
     * @param brandsId
     * @author Tansj
     * @since 2019/11/14
     */
    @ApiOperation(notes = "品系型查询界面车系下拉框", value = "品系型查询界面车系下拉框")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/brandsdict/{brandsId}/seriessdictAll")
    public List<SeriesDictVO> querySeriesDictAll(@PathVariable (value = "brandsId") String brandsId) {
        return seriesService.querySeriesDictAll(brandsId);
    }

    /**
     * 品系型查询界面车型下拉框
     *
     * @param brandsId
     * @author Tansj
     * @since 2019/11/18
     */
    @ApiOperation(notes = "品系型查询界面车型下拉框", value = "品系型查询界面车型下拉框")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/brandsdict/{brandsId}/seriessdictAll/{seriesId}/modelsdictAll")
    public List<ModelDictVO> queryModelDictAll(@PathVariable (value = "brandsId") String brandsId,
                                               @PathVariable (value = "seriesId") String seriesId) {
        return modelService.queryModelDictAll(brandsId, seriesId);
    }

    /**
     * 品系型查询界面配置下拉框
     *
     * @param brandsId
     * @author Tansj
     * @since 2019/11/18
     */
    @ApiOperation(notes = "品系型查询界面配置下拉框", value = "品系型查询界面配置下拉框")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/brandsdict/{brandsId}/seriessdictAll/{seriesId}/modelsdictAll/{modelsId}/packagedictAll")
    public List<VehicleProductPackageVO> queryPackageDictAll(@PathVariable (value = "brandsId") String brandsId,
                                               @PathVariable (value = "seriesId") String seriesId,
                                               @PathVariable (value = "modelsId") String modelsId) {
        return packageService.queryPackageDictAll(brandsId, seriesId,modelsId);
    }

    /**
     * 新增编辑界面本店面品牌下拉框
     *
     * @author Tansj
     * @since 2019/11/15
     */
    @ApiOperation(notes = "新增编辑界面本店面品牌下拉框", value = "新增编辑界面本店面品牌下拉框")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/queryBrandDictOwner")
    public List<BrandDictVO> queryBrandDictOwner() {
        return brandService.queryBrandDictOwner();
    }

    /**
     * 新增编辑界面本店面车系下拉框
     *
     * @param brandsId
     * @author Tansj
     * @since 2019/11/18
     */
    @ApiOperation(notes = "新增编辑界面本店面车系下拉框", value = "新增编辑界面本店面车系下拉框")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/brandsdict/{brandsId}/queryBrandDictOwner")
    public List<SeriesDictVO> querySeriesDictOwner(@PathVariable (value = "brandsId") String brandsId) {
        return seriesService.querySeriesDictOwner(brandsId);
    }

    /**
     * 新增编辑界面本店面车型下拉框
     *
     * @param brandsId
     * @author Tansj
     * @since 2019/11/18
     */
    @ApiOperation(notes = "新增编辑界面本店面车型下拉框", value = "新增编辑界面本店面车型下拉框")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/brandsdict/{brandsId}/seriessdictAll/{seriesId}/queryBrandDictOwner")
    public List<ModelDictVO> queryModelDictOwner(@PathVariable (value = "brandsId") String brandsId,
                                                  @PathVariable (value = "seriesId") String seriesId) {
        return modelService.queryModelDictOwner(brandsId, seriesId);
    }
    
    /**
     * 新增编辑界面本店面配置下拉框
     *
     * @param brandsId
     * @author zhangys
     * @since 2020/2/25
     */
    @ApiOperation(notes = "新增编辑界面本店面配置下拉框", value = "新增编辑界面本店面配置下拉框")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/brandsdict/{brandsId}/seriessdictAll/{seriesId}/modelsdict/{modelId}/queryBrandDictOwner")
    public List<PackageDictVO> queryModelDictOwner(@PathVariable (value = "brandsId") String brandsId,
                                                  @PathVariable (value = "seriesId") String seriesId,
                                                  @PathVariable (value = "modelId") String modelId) {
        return modelService.queryPackageDictOwner(brandsId, seriesId,modelId);
    }

    @GetMapping("/seriess/all")
    @ApiOperation(notes = "根据登录信息返回车系数据", value = "根据登录信息返回车系数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    public List<VehicleProductSeriesVO> queryVehicleProductSeries(SeriesQueryDTO seriesQueryDTO) {
        return seriesService.queryVehicleProductSeries(seriesQueryDTO);
    }

    /**
     * 根据查询条件返回对应的车型数据
     *
     * @param modelQueryDTO
     * @author Tansj
     * @since 2019/11/15
     */
    @GetMapping("/models/alls")
    @ApiOperation(notes = "根据查询条件返回车型", value = "根据查询条件返回车型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    public List<VehicleProductModelVO> queryVehicleProductModelsAll(ModelQueryDTO modelQueryDTO) {
        return modelService.queryVehicleProductModel(modelQueryDTO);
    }


    /**
     * 根据查询条件返回配置
     * @param packageQueryDTO
     * @return
     */
    @GetMapping("/packages/all")
    @ApiOperation(notes = "根据查询条件返回配置", value = "根据查询条件返回配置")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    public List<VehicleProductPackageVO> queryVehicleProductPackage(PackageQueryDTO packageQueryDTO) {
        return packageService.queryVehicleProductPackage(packageQueryDTO);
    }

    /**
     *
     * @param optionQueryDTO
     * @return
     */
    @GetMapping("/options/all")
    @ApiOperation(notes = "根据查询条件返回选装", value = "根据查询条件返回选装")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    public List<VehicleProductOptionVO> queryVehicleProductOption(OptionQueryDTO optionQueryDTO) {
        return vsOptionService.queryVehicleProductOption(optionQueryDTO);
    }

    /**
     * 品系型查询界面配置选装下拉框
     *
     * @param brandsId, seriesId, modelsId, packageId
     * @return java.util.List<com.yonyou.cyxdms.basedata.service.vo.packages.VehicleProductPackageVO>
     * @author caozx
     * @since 2020/12/14
     */
    @ApiOperation(notes = "品系型查询界面配置选装下拉框", value = "品系型查询界面配置选装下拉框")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    @GetMapping("/brandsdict/{brandsId}/seriessdictAll/{seriesId}/modelsdictAll/{modelsId}/packagedictAll/{packageId}/optiondictAll")
    public List<VehicleProductOptionVO> queryOptipnDictAll(@PathVariable (value = "brandsId") String brandsId,
                                                             @PathVariable (value = "seriesId") String seriesId,
                                                             @PathVariable (value = "modelsId") String modelsId,
                                                             @PathVariable (value = "packageId") String packageId) {
        return vsOptionService.queryOptipnDictAll(brandsId, seriesId, modelsId, packageId);
    }


    /**
     *
     * @param optionQueryDTO
     * @return
     */
    @PostMapping("/options/allNewQuery")
    @ApiOperation(notes = "根据查询条件返回选装", value = "根据查询条件返回选装")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", required = true, dataType = "Long", paramType = "header", value = "userId"),
    })
    public List<VehicleProductOptionVO> queryVehicleProductOptionNewQuery(OptionQueryDTO optionQueryDTO) {
        return vsOptionService.queryVehicleProductOptionNewQuery(optionQueryDTO);
    }



    @GetMapping("/seriesModelTree")
    public List<SeriesModelTreeDto> getSeriesModelTree(){
        return modelService.getSeriesModelTree();
    }



}
